package com.um.jdy.platform.station.controller;

import com.um.jdy.common.device.entity.vo.FeeVO;
import com.um.jdy.platform.station.entity.dto.FeePageDTO;
import com.um.jdy.platform.station.entity.vo.FeeListVO;
import com.um.jdy.platform.station.manager.*;
import com.um.springboot.starter.annotation.ApiPermission;
import com.um.springboot.starter.annotation.TokenRequired;
import com.um.springboot.starter.entity.Page;
import com.um.springboot.starter.orm.controller.BaseController;
import com.um.springboot.starter.orm.entity.Response;
import com.um.springboot.starter.orm.params.PageParams;
import com.um.springboot.starter.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 方案管理
 *
 * @author cs
 * 日期 2023/5/25
 * 版权所有 广州优匠科技有限公司
 */
@Api(tags = "方案管理")
@Validated
@RestController
@RequestMapping("/api/v1/cms/fee")
@ApiPermission("fee")
@TokenRequired
public class FeeController extends BaseController<FeeManager> {

    /**
     * 查询分页
     *
     * @param params
     * @return
     */
    @ApiPermission("page")
    @ApiOperation(value = "查询分页")
    @PostMapping("/fee_page")
    public Response<Page<FeeListVO>> getFeePage(@RequestBody FeePageDTO params) {
        PageParams pageParams = params.toPageParams(new String[]{"name","platformMerchantId","deviceType"},new String[]{"s.name","s.platform_merchant_id","device_type"});
        return manager.getFeePage(pageParams);
    }

    /**
     * 查询运营商下面的收费方案列表
     *
     * @param device_type
     * @return
     */
    @ApiPermission("list")
    @ApiOperation("查询运营商下面的收费方案列表")
    @GetMapping("/{merchant_id}/{device_type}/list")
    public Response<List<FeeVO>> getFeeList(@ApiParam(value = "运营商ID") @PathVariable String merchant_id,
                                            @ApiParam(value = "设备类型") @PathVariable String device_type) {
        return manager.getFeeList(merchant_id,device_type);
    }

    @ApiPermission("delete")
    @ApiOperation("删除")
    @DeleteMapping({"{id}"})
    public Response<Object> delete(@PathVariable String id) {
        return manager.delete(id);
    }

    @ApiPermission("delete_all")
    @ApiOperation("批量删除")
    @DeleteMapping
    public Response<Object> deleteIds(@ApiParam(value = "删除的id",required = true) @RequestBody List<String> ids) {
        return manager.deleteIds(ids);
    }

}
